Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
how to solve this error on react native " SyntaxError: JSON Parse error: Unexpected end of input "

i am working on React-native. and trying to calling a api but i am facing error in json

My error is [SyntaxError: JSON Parse error: Unexpected end of input]

my code is , please

 fetch('https://example.com/api/xyz_api.php', {
      method: 'POST',
      mode: 'no-cors',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        'mail_id': this.state.email_id,
        'pass':this.state.pass,
        'API_KEY':'API9723887855',
      })
    }).then((response) => response.json())
    .then((json) => {
      //this._storeData(json.flag);
      console.log(json);
      //this.setState({data:json});
      if(json.flag == '1')
      {
        _storeData();  
        this.props.navigation.navigate('MainScreen');

      }
      else if(json.flag == '2')
      {
        this.setState({error:'User not exist'});
        this._showDialog();
      }
      else if(json.flag == '3')
      {
        this.setState({error:'Incorrect Pasword'});
        this._showDialog();
      }

    }).catch((err) => { console.log(err); });
almost 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!